<template>
    <div :style="style.one">
        <span :style="style.left"></span>
        <ul class="box">
            <li>
                <span v-text="Lang.from[lang][11]">手续费</span>
                <span v-text="sxf">0</span>
            </li>
            <li>
                <span v-text="msg[2]==1? Lang.from[lang][13]:Lang.from[lang][12]">s</span>
                <span v-text="re">0</span>
            </li>
        </ul>
    </div>
</template>

<script>
import {vpost, vlink} from '@api'
import style from './style.jsx'
import Lang from './lang.js'
export default {
	name: 'formitems',
	props: {
		msg: {
			default: null,
		},
	},
	data() {
		return {
			Lang,
			style,
			sxfbl: 0,
			fee: 0,
		}
	},

	computed: {
		lang() {
			return this.$store.state.setting.lang
		},
		ji() {
			return this.msg[1] || 0
		},
		sxf() {
		

			return this.numMulti(this.fee, this.ji)
		},
		re() {
		
			if (this.msg[2] == 1) {
				return this.add(this.ji, this.sxf)
			} else {
				return this.sub(this.ji, this.sxf)
			}
		},
	},

	mounted() {
		this.init()
	},
	created() {},
	methods: {
		init() {
			vpost(vlink.ddd.getFee).then(re => {
				this.fee = re.data.fee
			})
		},
		numMulti(num1, num2) {
			var m = 0,
				r1,
				r2
			var s1 = num1.toString()
			var s2 = num2.toString()
			try {
				m += s1.split('.')[1].length
			} catch (e) {}
			try {
				m += s2.split('.')[1].length
			} catch (e) {}
			r1 = Number(num1.toString().replace('.', ''))
			r2 = Number(num2.toString().replace('.', ''))
			return r1 * r2 / Math.pow(10, m)
		},
		add(arg1, arg2) {
			var r1, r2, m
			try {
				r1 = arg1.toString().split('.')[1].length
			} catch (e) {
				r1 = 0
			}
			try {
				r2 = arg2.toString().split('.')[1].length
			} catch (e) {
				r2 = 0
			}
			m = Math.pow(10, Math.max(r1, r2))
			return (arg1 * m + arg2 * m) / m
		},
		sub(arg1, arg2) {
			var r1, r2, m, n
			try {
				r1 = arg1.toString().split('.')[1].length
			} catch (e) {
				r1 = 0
			}
			try {
				r2 = arg2.toString().split('.')[1].length
			} catch (e) {
				r2 = 0
			}
			m = Math.pow(10, Math.max(r1, r2))
			//last modify by deeka
			//动态控制精度长度
			n = r1 >= r2 ? r1 : r2
			return ((arg1 * m - arg2 * m) / m).toFixed(n)
		},
	},
}
</script>

<style scoped>
.test {
}
.box {
	border-radius: 4px;
	border: 1px solid rgba(128, 128, 128, 0.329);
	width: 300px;
	height: 60px;
	line-height: 30px;
	font-size: 14px;
}
li {
	padding-left: 20px;
}
</style>